package com.liuke.study.jdbc;

import java.sql.*;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * TODO
 *
 * @author wangjwy
 * @date 2019-04-28 13:45:06
 * @since 1.0.0
 */
public class JdbcTest {

	public static void main(String[] args) {

		System.out.println(3|8);
		// 00000011
		// 00001000
		//
		// 0000111
		// jebc();

	}

	private static void jebc() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		Connection con = null;
		try {
			//通过驱动管理器获取连接---三个参数：URL, 用户名、密码
			//URL---统一资源定位符---格式如： http://192.168.5.12:9527/index.html
			//                         协议 :// 对方机器的IP地址:端口号/资源名
			String port = "3306";
			String host = "192.168.100.100";
			String userName = "root";
			String password = "root";
			String scheme = "test";
			con = DriverManager.getConnection("jdbc:mysql://"+ host+":"+ port +"/"+ scheme +"?relaxAutoCommit=true&useUnicode=true&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false&useSSL=false", userName, password);
			for (int i = 0; i < 300000; i++) {
				String sql = "INSERT INTO test.user(name, nick_name, display) VALUES (?, ?, ?);";
				PreparedStatement preparedStatement = con.prepareStatement(sql);
				preparedStatement.setString(1, UUID.randomUUID().toString());
				preparedStatement.setString(2, UUID.randomUUID().toString());
				preparedStatement.setString(3, UUID.randomUUID().toString());
				preparedStatement.execute();
			}

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally{
			/*
			 * 关闭连接
			 */
			if(con != null){
				try {
					con.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}

}
